using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace InfiniTec.DirectoryServices
{
    /// <summary>
    /// Exception thrown when more than one principal was found during a principal resolving.
    /// </summary>
    [Serializable]
    public sealed class AmbiguousIdentityException : Exception
    {
        private IList<ActiveDirectoryPrincipal> _Principals;

        /// <summary>
        /// Initializes a new instance of the <see cref="AmbiguousIdentityException"/> class.
        /// </summary>
        public AmbiguousIdentityException() {}


        /// <summary>
        /// Gets or sets the principals.
        /// </summary>
        /// <value>The principals.</value>
        public IList<ActiveDirectoryPrincipal> Principals
        {
            get { return _Principals; }
            set { _Principals = value; }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AmbiguousIdentityException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        public AmbiguousIdentityException(string message) : base(message) {}

        /// <summary>
        /// Initializes a new instance of the <see cref="AmbiguousIdentityException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="principals">The list of ambiguous principals</param>
        public AmbiguousIdentityException(string message, IList<ActiveDirectoryPrincipal> principals) : base(message)
        {
            _Principals = principals;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AmbiguousIdentityException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerException">The inner exception.</param>
        public AmbiguousIdentityException(string message, Exception innerException) : base(message, innerException) {}
	
        /// <summary>
        /// Initializes a new instance of the <see cref="AmbiguousIdentityException"/> class.
        /// </summary>
        /// <param name="context">The <see cref="StreamingContext"/> to recreate the exception from.</param>
        /// <param name="info">The <see cref="SerializationInfo"/> to recreate the exception from.</param>
        private AmbiguousIdentityException(SerializationInfo info, StreamingContext context): base(info, context) {}
    }
}
